Passed
Pull Request — master (#87)
by Mathieu
02:13 queued 49s
created

FileAndPayStub1588080086043.down   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
1
import {MigrationInterface, QueryRunner} from "typeorm";
2
3
export class FileAndPayStub1588080086043 implements MigrationInterface {
4
    name = 'FileAndPayStub1588080086043'
5
6
    public async up(queryRunner: QueryRunner): Promise<any> {
7
        await queryRunner.query(`CREATE TABLE "file" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "size" integer NOT NULL, "mimeType" character varying NOT NULL, "uploadedAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "PK_36b46d232307066b3a2c9ea3a1d" PRIMARY KEY ("id"))`, undefined);
8
        await queryRunner.query(`CREATE TABLE "pay_stub" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "date" TIMESTAMP NOT NULL, "fileId" uuid NOT NULL, "userId" uuid NOT NULL, CONSTRAINT "PK_6a3474cef7b4be2033694e1b2ae" PRIMARY KEY ("id"))`, undefined);
9
        await queryRunner.query(`ALTER TABLE "pay_stub" ADD CONSTRAINT "FK_252d4cbbedfa1f1fb66ada01a07" FOREIGN KEY ("fileId") REFERENCES "file"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined);
10
        await queryRunner.query(`ALTER TABLE "pay_stub" ADD CONSTRAINT "FK_e70c3a9343494ab691a33302fe5" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined);
11
    }
12
13
    public async down(queryRunner: QueryRunner): Promise<any> {
14
        await queryRunner.query(`ALTER TABLE "pay_stub" DROP CONSTRAINT "FK_e70c3a9343494ab691a33302fe5"`, undefined);
15
        await queryRunner.query(`ALTER TABLE "pay_stub" DROP CONSTRAINT "FK_252d4cbbedfa1f1fb66ada01a07"`, undefined);
16
        await queryRunner.query(`DROP TABLE "pay_stub"`, undefined);
17
        await queryRunner.query(`DROP TABLE "file"`, undefined);
18
    }
19
20
}
21